<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>试题 | Introduction</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    
    <link rel="prev" href="../../MyGitbook_new/js/Braces.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="4.6"
        data-chapter-title="试题"
        data-filepath="MyGitbook_new/js/shiti.md"
        data-basepath="../.."
        data-revision="Fri Dec 22 2017 15:27:24 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Introduction
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="MyGitbook_new/css/steps.html">
            
                
                    <a href="../../MyGitbook_new/css/steps.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        手机端跳转js
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="MyGitbook_new/css/dassss.html">
            
            <span><b>1.1.</b> 第一天</span>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="MyGitbook_new/css/day1.html">
            
                
                    <a href="../../MyGitbook_new/css/day1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        3D动画
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3" data-path="MyGitbook_new/js/regular.html">
            
                
                    <a href="../../MyGitbook_new/js/regular.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        正则
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4" data-path="MyGitbook_new/js/js.html">
            
                
                    <a href="../../MyGitbook_new/js/js.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        js
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="MyGitbook_new/js/function_js.html">
            
                
                    <a href="../../MyGitbook_new/js/function_js.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        函数的声明方式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="MyGitbook_new/js/call_apply_bind.html">
            
                
                    <a href="../../MyGitbook_new/js/call_apply_bind.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        JS中改变this指向的方法(call和apply、bind)
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="MyGitbook_new/js/Dom.html">
            
                
                    <a href="../../MyGitbook_new/js/Dom.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.</b>
                        
                        Dom入门教程图解
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="MyGitbook_new/js/Drag_drop.html">
            
                
                    <a href="../../MyGitbook_new/js/Drag_drop.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.</b>
                        
                        JS拖拽元素原理及实现
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="MyGitbook_new/js/Braces.html">
            
                
                    <a href="../../MyGitbook_new/js/Braces.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.</b>
                        
                        {} 大括号
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="4.6" data-path="MyGitbook_new/js/shiti.html">
            
                
                    <a href="../../MyGitbook_new/js/shiti.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.6.</b>
                        
                        试题
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../" >Introduction</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h3 id="js&#x8BD5;&#x9898;">js&#x8BD5;&#x9898;</h3>
<pre><code>&#x4EC0;&#x4E48;&#x662F;&#x95ED;&#x5305;&#xFF1F;&#x8BF7;&#x4E3E;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#x3002;
&#x95ED;&#x5305;&#x662F;&#x4E00;&#x4E2A;&#x53EF;&#x4EE5;&#x8BBF;&#x95EE;&#x5916;&#x90E8;&#x51FD;&#x6570;&#x4F5C;&#x7528;&#x57DF;&#x94FE;&#x4E2D;&#x7684;&#x53D8;&#x91CF;&#x51FD;&#x6570;&#xFF1B;
&#x95ED;&#x5305;&#x53EF;&#x4EE5;&#x8BBF;&#x95EE;&#x4E09;&#x79CD;&#x8303;&#x56F4;&#x7684;&#x53D8;&#x91CF;&#xFF1A;&#x8FD9;&#x4E09;&#x4E2A;&#x5177;&#x4F53;&#x4E3A;&#xFF1A;&#xFF08;1&#xFF09;&#x81EA;&#x5DF1;&#x8303;&#x56F4;&#x5185;&#x7684;&#x53D8;&#x91CF;&#xFF1B;&#xFF08;2&#xFF09;&#x5C01;&#x95ED;&#x51FD;&#x6570;&#x8303;&#x56F4;&#x5185;&#x7684;&#x53D8;&#x91CF;&#xFF1B;&#xFF08;3&#xFF09;&#x5168;&#x5C40;&#x53D8;&#x91CF;
</code></pre><pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
            /*
             *&#x5728;&#x62BD;&#x5956;&#x7684;&#x6D3B;&#x52A8;&#x4E2D;&#x7ECF;&#x5E38;&#x4F1A;&#x7528;&#x5230;&#x8FD9;&#x4E2A;&#x7B97;&#x6CD5;&#xFF0C;&#x4E0D;&#x540C;&#x5956;&#x9879;&#x7684;&#x83B7;&#x53D6;&#x6982;&#x7387;&#x4E0D;&#x540C;&#xFF0C;&#x8981;&#x6309;&#x6982;&#x7387;&#x53BB;&#x968F;&#x673A;&#x751F;&#x6210;&#x5BF9;&#x5E94;&#x7684;&#x5956;&#x54C1;
             *
             */
            function random(arr1, arr2) {
                var sum = 0,
                    factor = 0,
                    random = Math.random();

                for(var i = arr2.length - 1; i &gt;= 0; i--) {
                    sum += arr2[i]; // &#x7EDF;&#x8BA1;&#x6982;&#x7387;&#x603B;&#x548C;
                };
                random *= sum; // &#x751F;&#x6210;&#x6982;&#x7387;&#x968F;&#x673A;&#x6570;
                for(var i = arr2.length - 1; i &gt;= 0; i--) {
                    factor += arr2[i];
                    if(random &lt;= factor)
                        return arr1[i];
                };
                return null;
            };

            // test
            var a = [&apos;mac&apos;, &apos;iphone&apos;, &apos;vivo&apos;, &apos;10&#x5143;&#x4EE3;&#x91D1;&#x5238;&apos;];
            var b = [0.1, 0.2, 0.3, 0.4];
            console.log(random(a, b));
        &lt;/script&gt;
</code></pre>
                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../../MyGitbook_new/js/Braces.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: {} 大括号"><i class="fa fa-angle-left"></i></a>
        
        
    </div>
</div>

        
<script src="../../gitbook/app.js"></script>

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-livereload/plugin.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"livereload":{}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
